<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/template.xhtml">
     <ui:define name="content">
            <h:form>
            <br/>
            <br/>
                   <div class="middle">
                         <h:outputText style="color:red;"
                                             value="everything was done"
                                             rendered="#{decideReplacerBean.amTerminatTotul}"
                                             >
                         </h:outputText>
                   </div>
                   <br/>
                  
                   <br />
                   <div class="middle">
                         <h2>Inactive office managers replacer</h2>
                   </div>
                   <br />
                    <div class="middle">
                         <h:outputText style="color:grey;"
                                value=" The list of office managers to replace is empty"
                                rendered="#{empty decideReplacerBean.toReplaceUserList}">
                         </h:outputText>
                   </div>
                   <br/>
                   <h:panelGrid class="panelGrid"
                         rendered="#{not empty decideReplacerBean.toReplaceUserList}">
                         <f:facet name="header">
                                       SELECT AN INACTIVE OFFICE MANAGER TO REPLACE</f:facet>
                         <h:selectOneRadio id="radioUser" value="#{decideReplacerBean.repId}"
                                valueChangeListener="#{decideReplacerBean.updateReplacedId}"
                                onchange="submit()">
                                <f:selectItems value="#{decideReplacerBean.toReplaceUserList}"
                                       var="toReplaceUser" itemLabel="#{toReplaceUser.name}"
                                       itemValue="#{toReplaceUser.id}" />
                         </h:selectOneRadio>
                   </h:panelGrid>
                   <br />
                   <div class="middle">
                         <h:outputText style="color:#420133;"
                                value=" None of the office managers is active and though you cannot replace any user!"
                                rendered="#{decideReplacerBean.avemManageriActivi eq false}">
                         </h:outputText>
                   </div>
                   <br />
                   <h:panelGrid class="panelGrid middle"
                         rendered="#{decideReplacerBean.userDTO!=null and decideReplacerBean.avemManageriActivi}">

                         <div class="middle">
                                <h:outputText value=" Replace with &nbsp;"
                                       rendered="#{not empty decideReplacerBean.toReplaceUserList}">
                                </h:outputText>
                                <h:selectOneMenu id="select" value="#{decideReplacerBean.omId}"
                                       valueChangeListener="#{decideReplacerBean.updateReplacerId}"
                                       onchange="submit()"
                                       rendered="#{not empty decideReplacerBean.toReplaceUserList}">
                                       <f:selectItems value="#{decideReplacerBean.officeManagersList}"
                                             var="dataItem2" itemLabel="#{dataItem2.name}"
                                             itemValue="#{dataItem2.id}">
                                       </f:selectItems>
                                </h:selectOneMenu>
                                <h:commandButton class="button middle" value="Add Replacer"
                                       render="tabelRU tabelUR"
                                       actionListener="#{decideReplacerBean.performReplace}"
                                       onclick="if (! confirm('Are you sure you want to add this user as replacer?') ) { return false;}; return true;"
                                       rendered="#{not empty decideReplacerBean.toReplaceUserList}">
                                       <f:attribute name="addReplacer" value="#{dataItem}" />
                                       <f:attribute name="inactiveOfficeManager"
                                             value="#{decideReplacerBean.toReplaceUserList[0]}" />
                                </h:commandButton>
                         </div>
                   </h:panelGrid>
                   <br />
                   <br />
                   <h:dataTable id="tabelRU" class="table" border="1"
                         value="#{decideReplacerBean.replacedUserList}"
                         var="replacedUserDataItem"
                         rendered="#{not empty decideReplacerBean.replacedUserList}">
                         <h:column>
                                <f:facet name="header">
                                       REPLACED USER</f:facet>
                                <h:outputText value="#{replacedUserDataItem.name}"></h:outputText>
                         </h:column>
                         <h:column>
                                <f:facet name="header">
                                       REPLACER
                                       </f:facet>
                                <h:outputText
                                     value="#{decideReplacerBean.getOM(replacedUserDataItem.id).name}"></h:outputText>

                         </h:column>
                         <h:column>
                                <f:facet name="header">
                                       REPLACEMENT DONE
                                       </f:facet>
                                <h:commandButton class="trashBtn" value="REMOVE"
                                       render="tabelUR tabelRU"
                                       actionListener="#{decideReplacerBean.replacementDone}">
                                       <f:attribute name="replacedUser" value="#{replacedUserDataItem}" />
                                </h:commandButton>
                         </h:column>


                   </h:dataTable>
            </h:form>
     </ui:define>
</ui:composition>
</html>
